<!--
 * @Author: your name
 * @Date: 2021-10-26 19:55:22
 * @LastEditTime: 2021-10-26 20:03:19
 * @LastEditors: Please set LastEditors
 * @Description: then函数的实现,在成功或失败后的回调中拿到结果值
 * @FilePath: \implement-promise-manually\src\index2.html
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./promise.js"></script>
</head>

<body>

</body>
<script>
    let p = new MyPromise((resolve, reject) => {
        //    resolve("OK"); //-- 状态成功,结果为ok
        //  reject("Error")   //--状态失败。结果为error
        // throw "Errors"     // --状态失败。结果为error
    });
    // p.then((res)=>{
    //     console.log(res);
    // },(err)=>{
    //     console.log(err);
    // })
    let p1 = new Promise((resolve,reject) =>{
        // resolve("OK")
        reject("出错了")
    });
    p1.then(res=>{
        console.log(res);
    },(err)=>{
        console.log(err);
    })
</script>

</html>